<?php
session_start();
require "lib/db.php";
require "lib/category-function.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Category</title>
<link rel="stylesheet" type="text/css" href="css/home.css">
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>

<script>
	$(document).ready(function() {
			$("#category").css({"background-color":"#FFF",	
	"color":"#000"});
    });
</script>

<style>
	#content{
		overflow:scroll;
		height:510px;
		margin:2px 3px;
		opacity:0.8;
		text-align:center;
	}

</style>

</head>

<body>

<!--menu-->
<?php
require "menu.php";
?>

<!--content-->
<div id="content">
<table width="100%" border="1" cellspacing="0">
  <tr>
    <th colspan="4">List Categories</th>
  </tr>
  <tr>
    <th>CategoryID</th>
    <th>Category Name</th>
    <th>Description</th>
    <th><a href="add-category.php">Add Category</a></th>
  </tr>
	<?php
    $listcategory = getAllCategory();
	while($category = mysql_fetch_array($listcategory)){
		ob_start();
    ?>
  <tr>
    <td>{CategoryID}</td>
    <td>{CategoryName}</td>
    <td>{Description}</td>
    <td><a href="edit-category.php?categoryid={CategoryID}">Edit</a> - <a onClick="return confirm('Are you sure delete this category?');" href="delete-category.php?categoryid={CategoryID}">Delete</a></td>
  </tr>
 	<?php 
	$s = ob_get_clean();
	$s = str_replace("{CategoryID}","$category[CategoryID]",$s);
	$s = str_replace("{CategoryName}","$category[CategoryName]",$s);
	$s = str_replace("{Description}","$category[Description]",$s);
	echo $s;
	}
	?>
</table>

</div>

<!--footer-->
<?php
require "footer.php";
?>

</body>
</html>